package com.example.demo_01.controller;

import com.example.demo_01.service.AdminService;
import com.example.demo_01.util.ResultBean;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.Objects;

@RestController
@RequestMapping("/AdminController")
public class AdminController {
    @Autowired
    private AdminService adminService;
    @RequestMapping("/checkLogin")
    public ResultBean checkLogin(@RequestParam Map<String,String> map,HttpSession session   ){
        Object code=session.getAttribute("code");
        if(code!=null){
            if(code.toString().equals(map.get("code"))){
                return adminService.checkAdmin(map);
            }
        }
        return ResultBean.getInstance().fail("验证码输入有误!");
    }
    @RequestMapping("/exit")
    public void exit(HttpSession session){
        System.out.println("==================");
        session.invalidate();
    }
}
